namespace Sirius.Mapper.Internals
{
    using System;

    internal class InlineMapping<T> : IInlineMapping<T> 
        where T : new()
    {
        private readonly ITypeMapping<T> mapping;
        private readonly ISingleSet<T> set;

        public InlineMapping(ITypeMapping<T> mapping, ISingleSet<T> set)
        {
            this.mapping = mapping;
            this.set = set;
        }

        public IInlineMapping<T> Property<TResult>(string columnName, Func<T, TResult> getter, Action<T, TResult> setter)
        {
            mapping.Property(columnName, getter, setter);
            return this;
        }

        public IInlineMapping<T> Key<TResult>(string columnName, Func<T, TResult> getter, Action<T, TResult> setter)
        {
            mapping.Key(columnName, getter, setter);
            return this;
        }

        public IInlineMapping<T> Table(string tableName)
        {
            mapping.Table(tableName);
            return this;
        }

        public ISingleSet<T> End()
        {
            return set;
        }
    }
}